package server;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class ZhuoerServer {

	public static void main(String[] args) {
		try {
			ServerSocket st = new ServerSocket(6666);
			System.out.println(st);
			System.out.println("服务器启动了！");
			while (true) {
				Socket s = st.accept();
				try {
					System.out.println("ip:" + s.getInetAddress() + "，本地端口："
							+ s.getLocalPort() + "，远程端口：" + s.getPort());
					InputStream in = s.getInputStream();
					// OutputStream out = s.getOutputStream();
					BufferedReader br = new BufferedReader(
							new InputStreamReader(in));
					String str = null;
					while ((str = br.readLine()) != null) {
						System.out.println(str);
					}

					s.close();
				} catch (Exception e) {
					// TODO 自动生成的 catch 块
					e.printStackTrace();
				}
			}

		} catch (IOException e) {
			// TODO 自动生成的 catch 块
			e.printStackTrace();
		}

	}

}
